home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / styleitem.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-06-20  |  7.0 KB  |  201 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7.  
  8. #ifndef STYLEITEM_H
  9. #define STYLEITEM_H
  10.  
  11. #include <QObject>
  12. #include <QList>
  13. #include <QPair>
  14.  
  15. class QString;
  16. class QStringList;
  17. class ScribusDoc;
  18. class QTabWidget;
  19.  
  20. /** RemoveItem.first will be the style to remove and RemoveItem.second
  21.  *  will be the one used in place of the deleted style */
  22. typedef QPair<QString, QString> RemoveItem;
  23.  
  24. /** StyleName.first is the name of the style and StyleName.second is the
  25.  *  name of the parent style or QString::null if there's no parent for this style */
  26. typedef QPair<QString, QString> StyleName;
  27.  
  28. /**
  29.  * @brief Represents a style type that can be added to the Style Manager
  30.  * @brief palette.
  31.  *
  32.  * This class is ment to be used as a parent class for any style types
  33.  * that are wanted to be configured using the Style Manager palette.
  34.  * @author Riku Leino <riku@scribus.info>
  35.  * @date November 2005
  36.  */
  37. class StyleItem : public QObject {
  38.     Q_OBJECT
  39. public:
  40.     StyleItem();
  41.     virtual ~StyleItem();
  42.  
  43.     /** 
  44.      * @brief return the QWidget for editing style's properties
  45.      *
  46.      * This is the widget where the attributes of style are edited. It
  47.      * will be placed on the main tab widget's Properties page.
  48.      * Whenever a selected style is edited StyleItem should emit the
  49.      * signal selectionDirty() if it is the first time style is edited
  50.      * after applying previous changes.
  51.      */
  52.     virtual QTabWidget* widget() = 0;
  53.  
  54.     /** @brief name of the style (plural) (Paragraph Styles, Character Styles...) */
  55.     virtual QString typeNamePlural() = 0;
  56.  
  57.     /** @brief name of the style (singular) (Paragraph Style, Character Style...) */
  58.     virtual QString typeNameSingular() = 0;
  59.  
  60.     /**
  61.      * @brief Whenever style manager is shown attached StyleItems get the current doc
  62.      * @brief passed to them with this function.
  63.      */
  64.     virtual void setCurrentDoc(ScribusDoc *doc) = 0;
  65.  
  66.     /**
  67.      * @brief existing styles in this category
  68.      *
  69.      * return the names of cached styles (even if those are changed)
  70.      * @param reloadFromDoc should the styles be loaded from the document or
  71.      * should function return currently cached and possibly changed styles
  72.      * @return Name of the styles and their parent as a QValueList.
  73.      * StyleName::first is the style name and StyleName::second it's parent's name.
  74.      * If the StyleItem has no parent StyleName::second should be set to QString::null.
  75.      */
  76.     virtual QList<StyleName> styles(bool reloadFromDoc = true) = 0;
  77.  
  78.     /** 
  79.      * @brief Reload styles and remove all cached (and possibly changed ones).
  80.      *
  81.      * This function will be called whenever a user clicks on the reset button.
  82.      * Resetting styles means loading them from the doc replacing all cached styles
  83.      * and without applying changes to the previously cached styles.
  84.      **/
  85.     virtual void reload() = 0;
  86.  
  87.     /**
  88.      * @brief Whenever this function is called StyleItem must update the main
  89.      * @brief widget with the corresponding data.
  90.      *
  91.      * Whenever user selects a style from the style list in the manager
  92.      * this slot is called from the StyleItem. StyleItem must then update
  93.      * the main widget with the data related to the selected item and then
  94.      * just wait for apply() to apply the changes user made (with the
  95.      * main widget). When implementing this method one should note that
  96.      * there may be more than a single style selected.
  97.      * @param styleNames styles selected for editing
  98.      */
  99.     virtual void selected(const QStringList &styleNames) = 0;
  100.  
  101.     /**
  102.      * @brief Return the name of the style in this category applied to the
  103.      * @brief selected object(s) in the current document or QString::null
  104.      * @brief if there is no selection in the document.
  105.      *
  106.      * If there are multiple objects selected only return a style name if the same style
  107.      * is applied on all selected objects. If they doesn't share the same style then
  108.      * return QString::null.
  109.      */
  110.     virtual QString fromSelection() const = 0;
  111.  
  112.     /** 
  113.      * @brief Apply style called styleName to the documents current selection
  114.      * @param styleName name of the style to be applied to the documents current selection
  115.      */
  116.     virtual void toSelection(const QString &styleName) const = 0;
  117.  
  118.     /**
  119.      * @brief Create a new temp. style with default values and return the
  120.      * @brief name of the newly created style.
  121.      * @return name of the created style
  122.      */
  123.     virtual QString newStyle() = 0;
  124.  
  125.     /**
  126.      * @brief Create a new temp. style which is a clone of the style called fromStyle.
  127.      * @param fromStyle name of the style to clone
  128.      * @return name of the created style
  129.      */
  130.     virtual QString newStyle(const QString &fromStyle) = 0;
  131.  
  132.     /**
  133.      * @brief apply changes made to the currently selected style(s)
  134.      *
  135.      * When a user has edited a style (s)he can either cancel or apply
  136.      * changes. On cancel and ok button clicks no action is needed from
  137.      * the StyleItem but if a user chooses to press button apply StyleItem's
  138.      * function apply() is called and StyleItem must upgrade the style
  139.      * and apply it where ever that style is used in the document.
  140.      * (cancel will be disabled after this)
  141.      */
  142.     virtual void apply() = 0;
  143.  
  144.     /**
  145.      * @brief When SM switches to or away from edit mode this function is called
  146.      * @param isOn true if SM is in edit mode false if SM has just closed edit mode
  147.      */
  148.     virtual void editMode(bool isOn) {};
  149.  
  150.     /** @brief returns if the style is a default style */
  151.     virtual bool isDefaultStyle(const QString &stylename) const = 0;
  152.  
  153.     /** @brief set if the style is a default style */
  154.     virtual void setDefaultStyle(bool ids) = 0;
  155.     
  156.     /** @brief returns the key combination for the style's shortcut */
  157.     virtual QString shortcut(const QString &stylename) const = 0;
  158.  
  159.     /** @brief set the key combination for the selected style's shortcut */
  160.     virtual void setShortcut(const QString &shortcut) = 0;
  161.  
  162.     /**
  163.      * @brief User has requested to delete all the selected styles
  164.      * @param removeList list of styles to be deleted. RemoveItem::first is
  165.      * the style to be deleted and RemoveItem::second is the style to replace
  166.      * the deleted style with. If no replacement was requested RemoveItem::second
  167.      * has been set to QString::null.
  168.      */
  169.     virtual void deleteStyles(const QList<RemoveItem> &removeList) = 0;
  170.  
  171.     /** @brief Called when the currently selected style's name has changed */
  172.     virtual void nameChanged(const QString &newName) = 0;
  173.  
  174.     /** @brief Return a unique name for a style using the base in the name */
  175.     virtual QString getUniqueName(const QString &base) = 0;
  176.  
  177.     /** @brief reload all the gui strings whenever this method is called */
  178.     virtual void languageChange() = 0;
  179.  
  180.     /** @brief document unit has been changed, upgrade widgets  */
  181.     virtual void unitChange() = 0;
  182.  
  183.     // do not implement this in derived classes
  184.     QString typeName() { return typeNamePlural(); };
  185.  
  186. /*
  187.     Emit this signal when selection has been edited. SM knows to highlight the
  188.     edited styles based on this signal.
  189. signals:
  190.     selectionDirty();
  191. */
  192.  
  193. private:
  194.     /* hide these two, StyleItem is not ment to be copied */
  195.     StyleItem(const StyleItem&);
  196.     void operator=(const StyleItem&);
  197.  
  198. };
  199.  
  200. #endif
  201.